package logic

import (
	"context"
	"test-demo/user_srv/user"

	"test-demo/api/internal/svc"
	"test-demo/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RealTestLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRealTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RealTestLogic {
	return &RealTestLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RealTestLogic) RealTest(req *types.RealTestReq) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	res, _ := l.svcCtx.UserServer.RealTest(context.Background(), &user.RealRequest{
		Realname: req.RealName,
		Idcode:   req.IdCode,
	})
	if res.Status != "1" {
		return &types.Response{
			Code:    10001,
			Message: "实名认证失败",
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "实名认证成功",
		Data:    nil,
	}, nil
}
